#pragma comment(linker, "/STACK:10000000")
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <set>
#include <map>
#include <cstdio>
#include <cassert>
#include <string>
#include <cstring>
#define ldb long double
#define LL long long
#define fi first
#define se second
#define fill(a, c) memset(a, c, sizeof(a))
#define sqr(a) ((a) * (a))
#define nextLine() {int c = 0; while((c = getchar()) != 10 && c != EOF);}
#define debug(a) cerr << #a << " = " << a << " ";
#define debugl(a) cerr << #a << " = " << a << "\n";
const ldb LDINF = 9128739847123.00;
const ldb eps = 1e-6;
const int INF = 1 << 30;
const ldb pi = fabsl(atan2(0.0, -1.0));
using namespace std;

class Point 
{
    public:
        ldb x, y;
        ldb abs()
        {
            return sqrt(x * x + y * y);
        }
        ldb abs2()
        {
        	return x * x + y * y;
        }
};

Point operator - (const Point &p1, const Point &p2)
{
    Point p;
    p.x = p1.x - p2.x;
    p.y = p1.y - p2.y;
    return p;
}

ldb operator * (const Point &p1, const Point &p2)
{
    return p1.x * p2.x + p1.y * p2.y;
}


class Line
{
    public:
        ldb a, b, c;
        ldb at(const Point &p)
        {
            return p.x * a + p.y * b + c;

        }
};

              
Point p[1010];
int n;
int Intersect(Line &l1, Line &l2, Point &p)
{
    ldb d = l1.a * l2.b - l2.a  * l1.b;
    if (fabsl(d) < eps) return 0;
    p.x = (-l1.c * l2.b + l2.c * l1.b) / d;
    p.y = (-l1.a * l2.c + l2.a * l1.c) / d;
    return 1;
}

int vx, vy;


void Load()
{
    cin >> n;
    int i;
    for (i = 0; i < n; i++)
    {
        cin >> p[i].x >> p[i].y;
    }
}

void Intersect(const Point &p1, const Point &p2, ldb &c, ldb &d)
{
    Line l1, l2;
    l1.a = p1.y - p2.y;
    l1.b = p2.x - p1.x;
    l1.c = -(l1.a * p1.x + l1.b * p1.y);
    l2.a = p[0].y - p[1].y;
    l2.b = p[1].x - p[0].x;
    l2.c = -(l2.a * p[0].x + l2.b * p[0].y);
    Point p;
    int t = Intersect(l1, l2, p);
    if (t == 0)
    {
        if (l1.at(::p[0]) > -eps)
        {
            c = 0;
            d = 1;
        }
        else
        {
            c = 2.0;
            d = 2.0;
        }
        return;
    }
    ldb a = ((p - ::p[0]) * (::p[1] - ::p[0]))/(::p[1] - ::p[0]).abs2();
    if (a < -eps)
    {
    	if (l1.at(::p[0]) > eps)
    	{
    		c = 0.0;
    		d = 1.0;
    	}
    	else 
    	{
    		c = 2.0;
    		d = 2.0;
    	}
    }
    else if (fabsl(a) < eps)
    {
    	if (l1.at(::p[1]) > eps)
    	{
			c = 0.;
			d = 1.;
    	}
    	else
    	{
    		c = 0.;
    		d = 0.;
    	}
    }
    else 
    {
    	if (l1.at(::p[0]) > eps)
    	{
    		d = a;
    		c = 0.;	
    	}
    	else
    	{
    		c = a;
    		d = 1.0;
    	}
    }
}

int RoundDown(ldb a)
{
    if (a < -eps)
        return (int)(a - eps);
    else if (a > eps)
        return (int)(a + eps);
    else return 0;
}

int RoundUp(ldb a)
{
    if (a < -eps)
    {
       return fabsl(a - (int)(a-eps)) > eps ? (int)(a - eps) + 1 : (int)(a - eps); 
    }
    else if (a > eps)
    {
        return fabsl(a - (int)(a+eps)) > eps ? (int)(a + eps) + 1 : (int)(a + eps);
    }
    return 0;
}

void Solve()
{
    int i;
    ldb a = 0;
    ldb b = 1;
    ldb c, d;
    for (i = 2; i < n - 1; i++)
    {
        Intersect(p[(i + 1) % n], p[i], c, d);
        //cerr << i << " " << c << " " << d << "\n";
        a = max(a, c);
        b = min(b, d);
    }
 //   cerr << a << " " << b << "\n";
    int vx = (int)(fabsl(p[1].x - p[0].x) + eps);
    int vy = (int)(fabsl(p[1].y - p[0].y) + eps);
  //  cerr << vx << " " << vy << "\n";
   	int g = __gcd(vx, vy);
  // 	cerr << g << "\n";
   	a *= g;
   	b *= g;
 //  	cerr << a << " " << b << "\n";
    if (a > b + eps)
    {
        cout << 0;
        return;
    }
    else
    {
        cout << RoundDown(b) - RoundUp(a) + 1;
    }
}

#define file "e"
int main()
{
    #ifndef ONLINE_JUDGE
    freopen(file".in", "rt", stdin);
    freopen(file".out", "wt", stdout);
    #endif
    Load();
    Solve();
    return 0;
}